import torch
a = torch.Tensor([[1, 2], [3, 4]])
print(a)
print(a.type())

# 指定shape
a = torch.Tensor(2,3)
print(a)
print(a.type())

a = torch.ones(2,3)
print(a)
print(a.type())

a = torch.eye(3,3)
print(a)
print(a.type())

a = torch.zeros(3,3)
print(a)
print(a.type())

b = torch.zeros(1,3)
b = torch.zeros_like(b)
print(b)
print(b.type())

'''随机'''
a = torch.rand(2,2)
print(a)
print(a.type())

# 正态分布, 均值0，标准差std随机
a = torch.normal(mean=0.0, std=torch.rand(5))
print(a)
print(a.type())

a = torch.normal(mean=torch.rand(5), std=torch.rand(5))
print(a)
print(a.type())

# 均匀分布
a = torch.Tensor(2,2).uniform_(-1,1)
print(a)
print(a.type())

# 序列, (起始，终止，步长)
a = torch.arange(0,11,3)
print(a)
print(a.type())

# 序列，（起始，终止，总个数），等间隔的
a = torch.linspace(0,10,4)
print(a)
print(a.type())

# 序列打乱
a = torch.randperm(10)
print(a)
print(a.type())




# numpy
import numpy as np

a = np.array([[1,2], [3,4]])
print(a)
print(type(a))